import request from '@/utils/requrest';

/**
 * 检查简码是否存在
 * @param code
 * @returns {*}
 */
export function checkSimpleCodeApi(code) {
    return request({
        method: 'POST',
        url: '/check/simple_code',
        data: {
            code: code
        }
    });
}

export function getTransferData(uid) {
    return request({
        method: 'GET',
        url: '/transfer/' + uid
    }).then(({data}) => {
        if (data.data.id) {
            return data.data;
        } else {
            location.replace('/static/404.html');
            return {};
        }
    });
}

export function addTransferRecord() {
    return request({
        method: 'POST',
        url: '/transfer/'
    }).then(({data}) => {
        location.replace('/?uid=' + data.data);
        return data.data;
    });
}

export function deleteTransferRecord(uid) {
    return request({
        method: 'DELETE',
        url: '/transfer/' + uid
    }).then(({data}) => {
        location.replace('/');
        return data.data;
    });
}
